/**
 * Created by zero on 2016/1/23.
 */
angular.module('meBindMemberServices', [])

  .factory('BindMember', function ($resource, $rootScope, ENV, Storage) {

    //设置访问接口路径
    var APIUrl = ENV.api;

    //访问获取用户信息的接口
    var bindMemberResource = $resource(APIUrl + "memberLogin/bindMemberAccount.do");
    var deleteAccountResource = $resource(APIUrl + "memberLogin/deleteAccount.do");

    var bindMemberInfo;


    return {
      bindMemberAccount : function (memberInfo){
        bindMemberResource.save(
          {
            member_phone : memberInfo.username,
            member_password : memberInfo.password,
            member_id : memberInfo.memberId
          },
          function (data){
            bindMemberInfo = data;
            $rootScope.$broadcast('BindMember.bindMember');
          }
        );
      },

      getBindMemberInfo : function (){
        return bindMemberInfo;
      },

      deleteAccount : function (memberId){
        deleteAccountResource.save(
          {
            member_id : memberId
          },
          function (data) {
          }
        );
      }
    }

  });
